<?php
	namespace Admin\Controller;
	use Think\Controller;
	class LoginController extends Controller{
		public function login(){
			$this->display();
		}
		//处理登录
		public function dologin(){
			//判断是否为空
			//接收数据
			$data['name']=$_POST['name'];
			$data['pwd']=md5($_POST['pwd']);

			//M
			$model =D('AdminUser');
			$res=$model->getFind($data);
			if($res){
				//登录成功
				$_SESSION['admin']=$res;

				//跳转到首页
				$this->success('登录成功',U('Index/index'),2);

			}else{
				$this->error('登录错误',U('Login/login'));
			}
		}

		public function Loginout(){
			unset($_SESSION['admin']);
			$this->redirect('Login/login');
		}
	}